%{
#include <string.h>
#include "tp.tab.h"

//para contar filas y columnas:
#define INC_COL col += yyleng
int row = 1, col = 1;
%}

def	(?i:define)
move	(?i:move)
scale	(?i:scale)
rotate	(?i:rotate) 
repeat	(?i:repeat)
circle	(?i:circle) 
box	(?i:box) 
digit	[0-9]
dseq      {digit}+
dseq_opt  {digit}*
frac      {dseq_opt}"."{dseq}|{dseq}"."
sfrac     [-+]?{frac}
name	[a-zA-Z][a-zA-Z0-9]*

%%

%{
	int i;
%}

{def}		{INC_COL; return DEFINE;}
{move}		{INC_COL; return MOVE;}
{scale}		{INC_COL; return SCALE;}
{rotate}	{INC_COL; return ROTATE;}
{repeat}	{INC_COL; return REPEAT;}
{circle}	{INC_COL; return CIRCLE;}
{box}		{INC_COL; return BOX;}

[-+]?{dseq}     {INC_COL; yylval.intval = atoi(yytext); return INT;}

{sfrac}		{INC_COL; yylval.floatval = atof(yytext); return FLOAT;}

{name}  	{INC_COL; yylval.strval = yytext; 
		 for (i = 0; i < yyleng; i++) 
			yytext[i] = tolower(yytext[i]);
		 return NAME; }

([ \t])+	{INC_COL;/*ignorar espacios, tabs, enter*/}
\n			{row++; col = 1;}

.		{INC_COL; return yytext[0];/*otros caracteres pasan igual*/}

%%

